<template>
	<scroll-view class="singer" scroll-y="true">
		<!-- tag标签 -->
		<view class="singer-tags">
			<scroll-view class="singer-tags-scroll" scroll-x="true">
				<view class="singer-tags-area">
					<view :class="{active: item.id === tagId.area}" class="singer-tag" v-for="(item, index) in area" :key="index"
						@click="changeTagState(item.id, 'area')">
						<text>{{item.name}}</text>
					</view>
				</view>
			</scroll-view>
			<scroll-view class="singer-tags-scroll" scroll-x="true">
				<view class="singer-tags-sex">
					<view :class="{active: item.id === tagId.sex}" class="singer-tag" v-for="(item, index) in sex" :key="index"
						@click="changeTagState(item.id, 'sex')">
						<text>{{item.name}}</text>
					</view>
				</view>
			</scroll-view>
			<scroll-view class="singer-tags-scroll" scroll-x="true">
				<view class="singer-tags-genre">
					<view :class="{active: item.id === tagId.genre}" class="singer-tag" v-for="(item, index) in genre" :key="index"
						@click="changeTagState(item.id, 'genre')">
						<text>{{item.name}}</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<!-- 歌手列表 -->
		<view class="singer-list">
			<view class="singer-list-item" v-for="(item, index) in singers" :key="index">
				<image class="singer-pic" :src="item.singer_pic"></image>
				<view class="singer-desc">{{item.singer_name}}</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import {
		getSinger
	} from "../../common/api/singer.js"
	export default {
		data() {
			return {
				area: [],
				sex: [],
				genre: [],
				index: [],
				singers: [],
				tagId: {
					area: -100,
					sex: -100,
					genre: -100
				},
				params: {
					area: -100,
					sex: -100,
					genre: -100,
					index: -100,
					sin: 0,
					cur_page: 1
				}
			}
		},
		onLoad() {
			this._getSinger()
		},
		methods: {
			_getSinger() {
				getSinger(this.params, res => {
					console.log(res)
					this._getTag(res.singerList.data.tags)
					this._getSingerlist(res.singerList.data.singerlist)
				})
			},
			_getTag(res) {
				this.area = res.area
				this.sex = res.sex
				this.genre = res.genre
				this.index = res.index
			},
			_getSingerlist(res) {
				this.singers = res
			},
			changeTagState(id, name) {
				this.tagId[name] = id
				this.params[name] = id
				this._getSinger()
			},
			
		}
	}
</script>

<style scoped>
	.singer {
		/* width: 96%; */
		height: 100vh;
		background: #e8e8e8;
	}

	.singer-tags {
		width: 100%;
		padding: 10rpx 0;
	}

	.singer-tags-scroll {
		width: 100%;
		margin-bottom: 15rpx;
	}

	.singer-tags-area {
		width: 1000rpx;
		display: flex;
	}

	.singer-tags-sex {
		width: 100%;
		display: flex;
	}

	.singer-tags-genre {
		width: 1840rpx;
		display: flex;
	}

	.singer-tag {
		width: 100rpx;
		padding: 10rpx;
		margin-left: 20rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}

	.singer-tag text {
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 26rpx;
	}

	.active {
		background: #4CD964;
		color: #FFFFFF;
	}

	.singer-list-item {
		display: flex;
		align-items: center;
		padding: 0 2%;
		margin-bottom: 15rpx;
	}

	.singer-list-item .singer-pic {
		width: 130rpx;
		height: 130rpx;
		border-radius: 50%;
	}

	.singer-list-item .singer-desc {
		margin-left: 20rpx;
	}

	radio-group {
		display: flex;
	}
	radio-group label {
		display: flex;
		width: 100rpx;
		padding: 10rpx;
		margin-left: 20rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		position: relative;
	}
	.radio {
		position: absolute;
		left: 0;
		width: 100%;
		height: 100%;
		border: none;
	}
</style>
